Socket
Socket
Sign inDemoInstall

fela-enforce-longhands

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fela-enforce-longhands

Fela enhancer that enforces longhand over shorthand properties


Version published
Weekly downloads
5.4K
decreased by-10.61%
Maintainers
1
Weekly downloads
 
Created
Source

fela-enforce-longhands

npm version npm downloads Bundlephobia

This enhancers implements are specific propertyPriority configuration that enforces longhand over shorthand properties. This enforces a certain order, but makes it deterministic which helps to prevent issues.

For example, paddingLeft will always overwrite the padding-left value from a padding property, no matter in which order they are rendered.

How it works

It uses a clever CSS specificity trick where repeated selectors increase the specificity and thus a prioritized over others.

For example, if we render the following style:

const style = {
  paddingLeft: 10,
  padding: 5,
}

the following CSS will be rendered respectively:

.a.a {
  padding-left: 10px;
}

.b {
  padding: 5px;
}

Check Selectors Level 3 for more information.

Installation

yarn add fela-enforce-longhands

You may alternatively use npm i --save fela-enforce-longhands.

Usage

import { createRenderer } from 'fela'
import enforceLonghands from 'fela-enforce-longhands'

const renderer = createRenderer({
  enhancers: [enforceLonghands()],
})

Configuration

Options
PropertyTypeDefaultDescription
borderModenone | directional | longhandnoneDefines which border properties take priority.
none will treat both second level properties (e.g. border-width or border-top) the same.
directional will prioritize e.g. border-top over border-width
longhand will prioritize e.g. border-width over border-top
Example
import { createRenderer } from 'fela'
import enforceLonghands from 'fela-enforce-longhands'

const renderer = createRenderer({
  enhancers: [
    enforceLonghands({
      borderMode: 'directional',
    }),
  ],
})

License

Fela is licensed under the MIT License.
Documentation is licensed under Creative Commons License.
Created with ♥ by @robinweser and all the great contributors.

Keywords

FAQs

Package last updated on 16 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc